home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 August / macformat-027.iso / mac / Shareware City / Developers / Oberon⁄F / System / Docu / Models (.txt) < prev    next >
Encoding:
Oberon Document  |  1994-06-07  |  13.6 KB  |  188 lines  |  [oODC/obnF]

  1. Documents.StdDocumentDesc
  2. Documents.DocumentDesc
  3. Containers.ViewDesc
  4. Views.ViewDesc
  5. Stores.StoreDesc
  6. Documents.ModelDesc
  7. Containers.ModelDesc
  8. Models.ModelDesc
  9. Stores.ElemDesc
  10. TextViews.StdViewDesc
  11. TextViews.ViewDesc
  12. TextModels.StdModelDesc
  13. TextModels.ModelDesc
  14. TextModels.AttributesDesc
  15. Geneva
  16. TextRulers.StdRulerDesc
  17. TextRulers.RulerDesc
  18. TextRulers.StdStyleDesc
  19. TextRulers.StyleDesc
  20. TextRulers.AttributesDesc
  21. Geneva
  22. HostPictures.StdViewDesc
  23. Geneva
  24. Dialog
  25. Views
  26. Files
  27. Ports
  28. Domains
  29. Fonts
  30. Stores
  31. Models
  32. Controllers
  33. Geneva
  34. model
  35. controller
  36. controller
  37. uld be
  38. Geneva
  39. Geneva
  40. 5.6 Models
  41. DEFINITION Models;
  42.     IMPORT Domains, Stores;
  43.     TYPE
  44.         Model = POINTER TO ModelDesc;
  45.         ModelDesc = RECORD (Stores.ElemDesc)
  46.             PROCEDURE (m: Model) Clone (): Model
  47.         END;
  48.         Context = POINTER TO ContextDesc;
  49.         ContextDesc = RECORD
  50.             PROCEDURE (c: Context) ThisModel (): Model;
  51.             PROCEDURE (c: Context) ThisDomain (): Domains.Domain;
  52.             PROCEDURE (c: Context) GetSize (VAR w, h: LONGINT);
  53.             PROCEDURE (c: Context) SetSize (w, h: LONGINT);
  54.             PROCEDURE (c: Context) Normalize (): BOOLEAN;
  55.             PROCEDURE (c: Context) Consider (VAR p: Proposal)
  56.         END;
  57.         Message = RECORD (Domains.Message)
  58.             model-: Model;
  59.             era-: LONGINT
  60.         END;
  61.         NeutralizeMsg = RECORD (Message) END;
  62.         UpdateMsg = RECORD (Message) END;
  63.         Proposal = RECORD (Domains.Message) END;
  64.     PROCEDURE NewDomain (shared: BOOLEAN): Domains.Domain;
  65.     PROCEDURE Broadcast (model: Model; VAR msg: Message);
  66.     PROCEDURE Domaincast (d: Domains.Domain; VAR msg: Message);
  67.     PROCEDURE BeginModification (m: Model);
  68.     PROCEDURE EndModification (m: Model);
  69.     PROCEDURE BeginScript (m: Model; name: Domains.OpName; VAR script: Domains.Operation);
  70.     PROCEDURE EndScript (m: Model; script: Domains.Operation);
  71.     PROCEDURE Do (m: Model; name: Domains.OpName; op: Domains.Operation);
  72.     PROCEDURE LastOp (m: Model): Domains.Operation;
  73.     PROCEDURE Bunch (m: Model);
  74.     PROCEDURE StopBunching (m: Model);
  75.     PROCEDURE Era (m: Model): LONGINT;
  76. END Models.
  77. Picture 5.6a Model-View-Controller Separation
  78. A model is one component of a Model-View-Controller triple. A model represents some data, without knowing how these data may be represented. Representation is performed by a view. There may be several views displaying the same model simultaneously, and possibly in different ways.
  79. After a model has been modified, a model message is broadcast in the domain to which this model belongs (e.g. the domain of the document of which the model is a part). Model messages are received by the appropriate views, such that these views can update the display according to the model modification which was performed.
  80. A modification of a model may be permanent, or reversible. To indicate a permanent modification, the procedures BeginModification/EndModification must be called before/after the modification(s). Reversible modifications ("undoable" operations) are implemented as Domains.Operation objects. Several operations on the same model can be combined into one (i.e. as a whole undoable/redoable) operation with the BeginScript/EndScript pair of procedures.
  81. A model may be a container, i.e. contain embedded views. An embedded view can communicate with the model in which it is embedded via a Context. A container model provides a context for each embedded view. Using its context, a view can inquire its current size, or it can try to change its size.
  82. TYPE Model
  83. Interface, Extension
  84. A model represents data, which may be presented by a view.
  85. Models are allocated by specific model directories, e.g. by Texts.dir.
  86. Models are used by commands which can operate on the data that is represented by the model.
  87. Models are extended whenever new kinds of displayable data need to be represented.
  88. PROCEDURE (m: Model) Clone (): Model
  89. Default, Extension
  90. Result type is narrowed to a model.
  91. Clone is used as part of a copy operation.
  92. Clone is sometimes extended in order to yield a narrower result type, as is done here for (s: Store) Clone (): Store.
  93. result.domain = NIL
  94. TYPE Context
  95. Interface
  96. A context object is part of the model-view recursion scheme of Oberon. A context is generated and maintained by a container model, and there is one context for every view embedded in the model. The context is carried by the view, so the view can communicate with its context (i.e. with the model in which it is embedded).
  97. A Context is used for the communication between container and contained view.
  98. A Context is extended for every container model.
  99. PROCEDURE (c: Context) ThisModel (): Model
  100. Default
  101. Returns the context's model. NIL may be returned if the context doesn't want to disclose its identity.
  102. ThisModel returns NIL as default, but may be overriden to return the context's model.
  103. ThisModel may be narrowed in an extension.
  104. PROCEDURE (c: Context) ThisDomain (): Domains.Domain
  105. Interface
  106. Returns the container's domain. The result may be NIL if the container has no domain (yet).
  107. PROCEDURE (c: Context) GetSize (VAR w, h: LONGINT)
  108. Interface
  109. Returns the width and height of the contained view in its container.
  110. w >= 0  &  h >= 0
  111. PROCEDURE (c: Context) SetSize (w, h: LONGINT)
  112. interface
  113. Requests the container to adapt the size of c's view to the given width and height. The container may or may not grant this request.
  114. PROCEDURE (c: Context) Normalize (): BOOLEAN
  115. Determines whether the contained view should normalize its persistent state upon externalization, and whether it should not make a modification of this state undoable.
  116. As an example, consider the scroll position of a text view: if the view is in a root context, i.e. in the outermost view level, it should write out position 0 (i.e. "normalized") as its current scroll position upon externalization, and it shouldn't make scroll operations undoable. However, if embedded in a non-root context, it should write out its current scroll position, and should make a scroll operation undoable.
  117. Normalize is called in a view's Externalize procedure and when it must be determined whether an operation needs to be undoable or not.
  118. PROCEDURE (c: Context) Consider (VAR p: Proposal)
  119. Emtpy
  120. If an embedded view wants its container to do something, it must ask for such a change by sending the container a Proposal via the Consider procedure. The container may, but need not, cooperate in an appropriate way. Oberon/F currently doesn't predefine proposals of its own.
  121. TYPE Message
  122. Interface, Extension
  123. Base type for all model messages.
  124. Messages are used to transmit information from a model to all views which display this model.
  125. Messages are extended to describe specific kinds of information to be transmitted.
  126. model: Model    model # NIL
  127. The model that has been changed.
  128. era-: LONGINT
  129. Used internally.
  130. TYPE UpdateMsg
  131. Extension
  132. All model messages which notify about a model modification must be extensions of UpdateMsg. A basic (unextended) UpdateMsg indicates that the message's model has changed in some unspecified way.
  133. UpdateMsgs are used to notify all views displaying a given model about a change of this model.
  134. UpdateMsgs are extended in order to update the display in more specific ways than to redraw the whole view (i.e. faster and with less screen flicker), i.e. to allow partial updates.
  135. TYPE NeutralizeMsg
  136. Extension
  137. This message is sent by the framework to indicate that marks (selection marks and the like) should be removed.
  138. TYPE Proposal
  139. Interface, Extension
  140. Base type for all proposals. A proposal is a message which a view can send to the model in which it is embedded.
  141. PROCEDURE NewDomain (shared: BOOLEAN): Domains.Domain
  142. Returns a new document domain.
  143. result # NIL
  144. result.shared = shared
  145. PROCEDURE Broadcast (model: Model; VAR msg: Message)
  146. Broadcast msg for model. Before broadcasting, parameter model is assigned to the message's model-field. The broadcast is actually performed only if model.domain # NIL.
  147. Broadcast is called by models whenever models need to transmit information to the views by which they are displayed.
  148. model # NIL    20
  149. msg.model = model
  150. PROCEDURE Domaincast (d: Domains.Domain; VAR msg: Message)
  151. This procedure sends a message to a particular domain, or does nothing if the domain is NIL.
  152. PROCEDURE BeginModification (m: Model)
  153. If model m is modified in a way that cannot be undone, the modification(s) must be bracketed by calls to BeginModification and EndModification.
  154. m # NIL    20
  155. PROCEDURE EndModification (m: Model)
  156. If model m is modified in a way that cannot be undone, the modification(s) must be bracketed by calls to BeginModification and EndModification.
  157. m # NIL    20
  158. PROCEDURE BeginScript (m: Model; name: Domains.OpName;
  159.                                                 VAR script: Domains.Operation)
  160. To make a sequence of undoable operations undoable as a whole, the sequence should be bracketed by calls to BeginScript and EndScript.
  161. m # NIL    20
  162. script # NIL
  163. PROCEDURE EndScript (m: Model; script: Domains.Operation)
  164. To make a sequence of undoable operations undoable as a whole, the sequence should be bracketed by calls to BeginScript and EndScript. The same script which has been returned in BeginScript must be passed to EndScript.
  165. m # NIL    20
  166. script # NIL    21
  167. PROCEDURE Do (m: Model; name: Domains.OpName; op: Domains.Operation)
  168. This procedure is called to execute an operation on a model. The operation's Do procedure is called, and the operation is recorded for a later undo.
  169. m # NIL    20
  170. op # NIL    21
  171. op.inUse
  172. PROCEDURE LastOp (m: Model): Domains.Operation
  173. This procedure returns the most recently executed operation on the given model. It can be used to bunch several actions into one operation, e.g. if a character is typed into a text, it may be bunched with the previously inserted character; such that an undo operates on the whole text typed in, and not on one character per undo.
  174. m # NIL    20
  175. PROCEDURE Bunch (m: Model)
  176. Notify model that another action was bunched to the most recently executed operation.
  177. m # NIL    20
  178. PROCEDURE StopBunching (m: Model)
  179. Prevents any further bunching on this model's current operation.
  180. PROCEDURE Era (m: Model): LONGINT
  181. Called internally.
  182. TextControllers.StdCtrlDesc
  183. TextControllers.ControllerDesc
  184. Containers.ControllerDesc
  185. Controllers.ControllerDesc
  186. Geneva
  187. Documents.ControllerDesc
  188.